home *** CD-ROM | disk | FTP | other *** search
- property carYpos, carXpos, CAR, carIsDrivingHori, carIsDrivingVert, myDirection, myCounter, myRatio, finalYpos, finalXpos, freezedCar
- global myGridArray, gGamesMasterObj, noWayBubList, BLOCKWIDTH, BLOCKHEIGHT
-
- on new me
- return me
- end
-
- on init me, xPos, yPos, spritenum, ratioNum
- set carXpos to xPos
- set carYpos to yPos
- set freezedCar to 0
- set finalXpos to xPos
- set finalYpos to yPos
- set CAR to spritenum
- set carIsDrivingHori to 0
- set carIsDrivingVert to 0
- set myDirection to 0
- set myCounter to 0
- set myRatio to ratioNum
- appear(me, "carN.PCT")
- end
-
- on appear me, membername
- puppetSprite(the CAR of me, 1)
- set the foreColor of sprite the CAR of me to 255
- set the ink of sprite the CAR of me to 8
- set the locH of sprite the CAR of me to ((the carXpos of me - 1) * BLOCKWIDTH) + (BLOCKWIDTH / 2)
- set the locV of sprite the CAR of me to ((the carYpos of me - 1) * BLOCKHEIGHT) + (BLOCKHEIGHT / 2)
- set the member of sprite the CAR of me to member membername
- append(the actorList, me)
- end
-
- on stepFrame me
- mainRoutine(me)
- end
-
- on mainRoutine me
- if carIsDrivingHori then
- set myCounter to myCounter + 1
- if myCounter > (BLOCKWIDTH / myRatio) then
- set finalXpos to carXpos
- set carIsDrivingHori to 0
- else
- set the locH of sprite CAR to the locH of sprite CAR + (myDirection * myRatio)
- end if
- else
- if carIsDrivingVert then
- set myCounter to myCounter + 1
- if myCounter > (BLOCKHEIGHT / myRatio) then
- set finalYpos to carYpos
- set carIsDrivingVert to 0
- else
- set the locV of sprite CAR to the locV of sprite CAR + (myDirection * myRatio)
- end if
- else
- if not freezedCar then
- case the keyPressed of gGamesMasterObj of
- 126:
- checkCar(me, 1)
- 124:
- checkCar(me, 2)
- 125:
- checkCar(me, 3)
- 123:
- checkCar(me, 4)
- end case
- end if
- end if
- end if
- end
-
- on checkCar me, indexNum
- if not carIsDrivingVert and not carIsDrivingHori then
- set myOptions to getIndex(me, myGridArray, carYpos, carXpos)
- if getAt(myOptions, indexNum) = 1 then
- killBubbles(gGamesMasterObj, noWayBubList)
- case indexNum of
- 1:
- set carYpos to carYpos - 1
- if nextSpaceFree(me) then
- set the member of sprite CAR to member "carN.PCT"
- moveVertical(me, -1)
- else
- set carYpos to carYpos + 1
- end if
- 2:
- set carXpos to carXpos + 1
- if nextSpaceFree(me) then
- set the member of sprite CAR to member "carE.PCT"
- moveHorizontal(me, 1)
- else
- set carXpos to carXpos - 1
- end if
- 3:
- set carYpos to carYpos + 1
- if nextSpaceFree(me) then
- set the member of sprite CAR to member "carS.PCT"
- moveVertical(me, 1)
- else
- set carYpos to carYpos - 1
- end if
- 4:
- set carXpos to carXpos - 1
- if nextSpaceFree(me) then
- set the member of sprite CAR to member "carW.PCT"
- moveHorizontal(me, -1)
- else
- set carXpos to carXpos + 1
- end if
- end case
- else
- if noWayBubList = [] then
- set horPos to the locH of sprite CAR
- set verPos to the locV of sprite CAR
- if horPos < 280 then
- set xPos to horPos + 15
- set hCode to 4
- else
- set xPos to horPos - 15
- set hCode to 2
- end if
- if verPos < 180 then
- set yPos to verPos + 15
- set vCode to 1
- else
- set yPos to verPos - 15
- set vCode to 3
- end if
- set bubbleObj to new(script "bubbleScript")
- set myMember to getAt(["band", "move", "miss"], random(3))
- appear(bubbleObj, xPos, yPos, myMember & vCode & hCode & ".PCT", noWayBubList)
- end if
- end if
- end if
- end
-
- on changeCar me, myString
- set myName to the name of the member of sprite the CAR of me
- set myDir to chars(myName, 4, 4)
- set the member of sprite the CAR of me to member string(myString & myDir & ".PCT")
- end
-
- on moveVertical me, direction
- set the myCounter of me to 0
- set the myDirection of me to direction
- set the carIsDrivingVert of me to 1
- end
-
- on moveHorizontal me, direction
- set the myCounter of me to 0
- set the myDirection of me to direction
- set the carIsDrivingHori of me to 1
- end
-
- on getIndex me, list, iPos, jPos
- return getAt(getAt(list, iPos), jPos)
- end
-
- on setIndex me, list, iPos, jPos, myValue
- setAt(getAt(list, iPos), jPos, myValue)
- end
-
- on destroy me
- set the memberNum of sprite the CAR of me to 0
- set pos to getPos(the actorList, me)
- if pos > 0 then
- deleteAt(the actorList, pos)
- end if
- return me
- end
-
- on nextSpaceFree me
- repeat with i = 2 to count(the actorList)
- set myObject to getAt(the actorList, i)
- if the CAR of myObject <> CAR then
- if (the carXpos of myObject = carXpos) and (the carYpos of myObject = carYpos) then
- return 0
- exit repeat
- end if
- end if
- end repeat
- return 1
- end
-